<?php

Raise::load('core.RaiseUIControl');
Raise::load('core.RaiseCollection');
Raise::load('core.RaiseFile');
Raise::load('core.RaiseTemplate');

/**
 * RaiseTemplateUIControl class
 * A RaiseUIControl that utilizes a template
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @abstract
 * @package Raise.Core.UI
 * @since 1.2
 */
abstract class RaiseTemplateUIControl extends RaiseUIControl {

    /**
     * The template or template file to use
     * @var string|RaiseFile
     */
    protected $template;

    /**
     * Creates a new RaiseTemplateUIControl
     * @param string|RaiseFile $t The template to use for this control
     */
    function __construct($t) {
        $this->template = new RaiseTemplate($t);
    }

    /**
     * Get the template or template file to use
     * @return RaiseTemplate
     */
    public function template(){
        return $this->template;
    }

    /**
     * Get the template or template file to use
     * @return RaiseCollection
     */
    public function fields(){
        return $this->template->fields();
    }

    /**
     * Return the final output of the control
     * @return string
     */
    public function output(){
        return $this->template->parse();
    }

}